package per.ace.orderdemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import per.ace.orderdemo.entity.Order;
import per.ace.orderdemo.service.OrderService;
import per.ace.orderdemo.util.SnowflakeIdUtils;

import java.time.Instant;

/**
 * @program: order-demo
 * @description: order web
 * @author: ace
 * @Date: 2020-06-03 18:20
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("create")
    public void create(@RequestBody Order order){

        order.setOrderId(SnowflakeIdUtils.nextId());
        order.setUserId(10000000023L);
        order.setCreateTime(Instant.now().toEpochMilli());

        orderService.createOrder(order);
    }
}
